home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / Presentations / STL & Modern C++ / STL3.cp < prev    next >
Encoding:
Text File  |  1999-06-25  |  721 b   |  38 lines  |  [TEXT/CWIE]

  1. // STL3.cp
  2. #include <iostream>
  3. #include <list>
  4. #include <string>
  5.  
  6. int main()
  7. {
  8.     typedef    std::list<char> MyList;
  9.     std::string    start("machack");
  10.     MyList    l(start.begin(), start.end());
  11.  
  12.     std::ostream_iterator<char>    out(std::cout);
  13.     std::cout << "  start: ";
  14.     std::copy(l.begin(), l.end(), out);
  15.  
  16.     std::cout << "\nremoved: ";
  17.     l.remove('c');
  18.     std::copy(l.begin(), l.end(), out);
  19.  
  20.     std::cout << "\n sorted: ";
  21.     l.sort();
  22.     std::copy(l.begin(), l.end(), out);
  23.  
  24.     std::cout << "\n unique: ";
  25.     l.unique();
  26.     std::copy(l.begin(), l.end(), out);
  27.  
  28.     std::cout << "\nreverse: ";
  29.     l.reverse();
  30.     copy(l.begin(), l.end(), out);
  31.     std::cout << "\n";
  32. }
  33. //   start: machack
  34. // removed: mahak
  35. //  sorted: aahkm
  36. //  unique: ahkm
  37. // reverse: mkha
  38.